package cn.iocoder.yudao.module.product.controller.app.spu.vo;

import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.dataobject.sku.ProductSkuDO;
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class AppProductSkuRespVO {
    @Schema(description = "一级分类列表")
    private List<AppProductSkuRespOptionVO> categories;
    @Schema(description = "二级分类列表")
    private List<AppProductSkuRespOptionVO> subCategories;
    @Schema(description = "商品列表")
    private List<AppProductSkuRespOptionVO> products;
    @Schema(description = "属性列表")
    private List<AppProductSkuRespPropertyVO> properties;
//    private List<ProductSkuDO> skus;

    @Schema(description = "最小购买数量")
    private Integer minNum;
    @Schema(description = "最大购买数量")
    private Integer maxNum;
    @Schema(description = "购买数量最小单位")
    private Integer stepNum;
    @Schema(description = "数量字段名")
    private String numLabel;

    //代理类型
    @Schema(description = "代理类型")
    @ExcelProperty("代理类型")
    private String proxyType;

    //验证方式
    @Schema(description = "验证方式")
    private String validateMethod;

    //终端数限制
    @Schema(description = "终端数限制")
    private String clientLimit;

    //白名单数量
    @Schema(description = "白名单数量")
    private String whitelistNum;

    //单IP带宽峰值
    @Schema(description = "单IP带宽峰值")
    private String maxBandwidth;

    //单次提取上限
    @Schema(description = "单次提取上限")
    private String maxExtract;

    //是否可附加隧道转发
    @Schema(description = "是否可附加隧道转发")
    private Integer canTunnelForwarding;

    //是否可选城市
    @Schema(description = "是否可选城市")
    private Integer canSelectCity;

    public AppProductSkuRespVO() {
        setCategories(new ArrayList<>());
        setSubCategories(new ArrayList<>());
        setProducts(new ArrayList<>());
        setProperties(new ArrayList<>());
//        setSkus(new ArrayList<>());
    }

    public AppProductSkuRespVO(List<ProductCategoryDO> topCategories, List<ProductCategoryDO> subCategories, List<ProductSpuDO> products) {
        setCategories(new ArrayList<>());
        setSubCategories(new ArrayList<>());
        setProducts(new ArrayList<>());
        setProperties(new ArrayList<>());
//        setSkus(new ArrayList<>());
        for (ProductCategoryDO category : topCategories) {
            getCategories().add(AppProductSkuRespOptionVO.fromProductCategory(category));
        }
        getCategories().get(0).setDefault(true);
        for (ProductCategoryDO category : subCategories) {
            getSubCategories().add(AppProductSkuRespOptionVO.fromProductCategory(category));
        }
        getSubCategories().get(0).setDefault(true);
        for (ProductSpuDO product : products) {
            getProducts().add(AppProductSkuRespOptionVO.fromProductSpu(product));
        }
        getProducts().get(0).setDefault(true);
    }
}
